<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/10/19 0019
 * Time: 下午 7:17
 */
header('Content-type:text/html;charset=utf-8');
$link = mysql_connect('localhost','root','123456');
if (!$link){
    die('连接数据库失败！'.mysql_error());
}
mysql_query('set names utf8');
mysql_query('use `itcast`');
$fields = array('e_dept','data_of_entry');
$sql_order = "";
$order = isset($_GET['order']) ? $_GET['order'] : '';
$sort = isset($GET['sort']) ? $_GET['sort'] :'';
if (in_array($order,$fields)) {
    if ($sort == 'desc') {
        $sql_order = "order by $order desc";
        $sort = 'asc';
    } else {
        $sql_order = "order by $order asc";
        $sort = 'desc';

    }
}